<template>
  <div>
      <el-row>
          <el-col :span="24" align="right">
              <div style="margin-top:10px">
                <el-button @click="addNewRecord" type="primary">添加巡查记录</el-button>
                <el-input style="width:200px" v-model="filters.inspecterName" placeholder="请输入巡查人姓名"></el-input>
                <el-date-picker v-model="filters.inspectDateTime" @change="changeDate" placeholder="请输入巡查日期"></el-date-picker>
                <el-select v-model="filters.enterpriseUSCcode" placeholder="所查企业统一社会信用代码">
                  <el-option v-for="v in Codes" :key="v.enterpriseUSCcode" :label="v.enterpriseName" :value="v.enterpriseUSCcode"></el-option>
                </el-select>
                <el-button type="primary" icon="search" @click="getgetInspectRecord">搜索</el-button>
                <el-button type="primary" @click="flushAll">刷新</el-button>
              </div>
              <el-row style="margin-top:20px">
                  <el-col :span="24">
                      <el-table border :data="list">
                          <el-table-column v-for="(v,k,i) in props" :key="v.id" :label="labels[i]" align="center">
                              <template scope="scope">
                                  <span>
                                      {{scope.row[k]}}
                                  </span>
                              </template>
                          </el-table-column>
                          <el-table-column label="操作" width="200" align="center">
                              <template scope="scope">
                                  <el-button type="text" @click="ckDetail(scope.row.inspectRecID)">查看详情</el-button>
                                  <!-- <el-button type="text" @click="editDrivers(scope.row.keyDriverID)">编辑</el-button>
                                  <el-button type="text" @click="deleteDrivers(scope.row.keyDriverID)">删除</el-button> -->
                              </template>
                          </el-table-column>
                      </el-table>
                  </el-col>
                  <el-col :span="24" style="margin-top:10px" align="right">
                      <el-pagination layout="prev, pager, next" :total="totalInfo" @current-change="handleCurrentChange">
                      </el-pagination>
                  </el-col>
              </el-row>
          </el-col>
      </el-row>

       <el-dialog top="5%" title="查看详情" :visible.sync="visible">
      <info :id="id"></info>
    </el-dialog>
  </div>
</template>

<script>
import * as api from '@/api/securityManage'
import info from "./InspectRecordInfo";
export default {
  components:{
    info:info
  },
  data() {
    return {
      filters: {
        inspecterName:null, // 巡查人姓名
        inspectDateTime:null,
        enterpriseUSCcode:null,
        page: 1,
        pageSize: 10
      },
      list: [
        {
          inspectRecID:'',//          bigint not null auto_increment,
          inspecterCertID:'',//       char(18) comment '巡查人身份证号',
          inspecterName:'',//         varchar(50) comment '巡查人姓名',
          inspectDateTime:'',//       datetime,
          inspectContent:'',//        varchar(500),
          enterpriseUSCcode:'',//     char(18) comment '所在企业统一社会信用代码',
          remarks:'',//               varchar(500) comment '备注',
        }
      ],
      totalInfo: 0,
      props: {
          inspectRecID:'',//          bigint not null auto_increment,
          inspecterCertID:'',//       char(18) comment '巡查人身份证号',
          inspecterName:'',//         varchar(50) comment '巡查人姓名',
          inspectDateTime:'',//       datetime,
        //   inspectContent:'',//        varchar(500),
          enterpriseUSCcode:'',//     char(18) comment '所在企业统一社会信用代码',
      },
      labels: ["编号", "巡查人身份证", "巡查人姓名", "巡查日期", "巡查企业"],
      Codes:[],
      visible:false,
      id:'01'
    };
  },
  methods: {
    flushAll() {
      this.filters.inspecterName = this.filters.inspectDateTime = this.filters.enterpriseUSCcode = null;
      this.getgetInspectRecord();
    },
    handleCurrentChange(val) {
      this.filters.page = val;
      this.getgetInspectRecord();
    },
    ckDetail(id) {
      this.id = id;
      this.visible = true;
      // this.$router.push({ path: "InspectRecordInfo", query: { id: id } });
    },
    addNewRecord() {
      this.$router.push("addInspectRecord");
    },
    changeDate(val) {
        this.filters.inspectDateTime = val
    },
    getgetInspectRecord() {
      api.getInspectRecInfo(this.filters).then(res=>{
        this.list = res.data.records
        this.totalInfo = res.data.page.totalCount
      })
    }
  },
  mounted() {
    this.getgetInspectRecord();
    api.getKeyEnterpriseUSCcode().then(res=>{
      this.Codes = res.data
    })
  }
};
</script>


<style scoped>

</style>
